<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>重新加载数据</title>
    <!-- ECharts单文件引入 -->
    <script src="../echarts-2.2.7/build/dist/echarts-all.js"></script>
    <script>
        // 修改图标数据
        function changeData(){
            // 重新加载数据
            myChart.setOption(option1);
        }
    </script>
</head>
<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="height:400px"></div>
<button type="button" onclick="changeData()">修改数据!</button>
</body>
</html>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts图表
    var myChart = echarts.init(document.getElementById('main'));

    // 图表1
    var option = {
        tooltip: {
            show: true
        },
        legend: {
            data:['销量']
        },
        xAxis : [
            {
                type : 'category',
                data : ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            }
        ],
        yAxis : [
            {
                type : 'value'
            }
        ],
        series : [
            {
                "name":"销量",
                "type":"bar",
                "data":[5, 20, 40, 10, 10, 20]
            }
        ]
    };

    // 图表2
    var option1 = {
        tooltip: {
            show: true
        },
        legend: {
            data:['销量']
        },
        xAxis : [
            {
                type : 'category',
                data : ["衬衫1","羊毛衫1","雪纺衫1","裤子1","高跟鞋1","袜子1"]
            }
        ],
        yAxis : [
            {
                type : 'value'
            }
        ],
        series : [
            {
                "name":"销量",
                "type":"bar",
                "data":[3, 20, 40, 10, 10, 20]
            }
        ]
    };

    // 为echarts对象加载数据
    myChart.setOption(option);
</script>